package com.haixiaoke.saas.common.utils;

import com.haixiaoke.saas.common.constant.Constants;
import com.haixiaoke.saas.common.constant.MessageConstants;

import java.util.HashMap;
import java.util.Map;

/**
 * 渠道名称拼接工具类
 * @author haixiaoke
 * @version 1.0.0
 * @date 2024/11/23
 */
public class ChannelNameUtil {

    // 存储对应状态和名称
    private static final Map<String, String> channelNames = new HashMap<>();

    static {
        channelNames.put(MessageConstants.PUSH_CHANNEL_ENTERPRISE_WECHAT, "企业微信");
        channelNames.put(MessageConstants.PUSH_CHANNEL_DING_TALK, "钉钉");
        // 可以根据需要添加更多的渠道
    }

    // 根据开关状态返回拼接的名称
    public static String getCombinedChannelNames(Map<String, String> states) {
        StringBuilder combinedName = new StringBuilder();

        for (Map.Entry<String, String> entry : states.entrySet()) {
            if (Constants.OPEN.equals(entry.getValue())) {
                if (combinedName.length() > 0) {
                    combinedName.append("，");
                }
                combinedName.append(channelNames.get(entry.getKey()));
            }
        }

        return combinedName.length() > 0 ? combinedName.toString() : "";
    }
}
